<#import "spring.ftl" as spring />
<#assign xhtmlCompliant = true in spring />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<title><@spring.message "title" /></title>
	<meta name="description" content="<@spring.message "title" />" />
	<link rel="stylesheet" href="<@spring.theme "css" />" type="text/css" media="screen,projection" />
	<script type="text/javascript" src="<@spring.theme "jQuery" />"></script>
	<script type="text/javascript" src="<@spring.theme "jSpinner" />"></script>
	<script type="text/javascript" src="<@spring.theme "jAlphaNumeric" />"></script>
	<script type="text/javascript">
		$(function() {

			$("#errors").addClass("important");

		    // Some id's contain periods so we pass those in here for a scrubbin.
			// Takes care of adding a '#' at the beginning and escaping all the periods.
			function clean(myid) { return '#'+myid.replace(/\./g,"\\."); }			

			$("#amount").numeric({allow:"."});
			$(clean("debitAccount.routingNumber")).numeric();
			$(clean("debitAccount.accountNumber")).numeric();

			$("#transactionForm").submit(function() {
				$("#errors").hide();
				$(".summary").hide();
				$("#spinme").spinner({
					height: 48,
					width: 48,
					speed: 50,
					image: '<@spring.theme "spinner" />'
				});
			});
		});
	</script>
</head>
<body>
	<div class="title"><@spring.message "title" /></div>
	<div id="content">
	<form id="transactionForm" method="POST">
		<div class="module">
			<div class="subModule">
				<label for="creditUserId"><@spring.message "creditUser" /></label>
				<@spring.formSingleSelect "webTransaction.creditUserId", userMap />
			</div>
		</div>
		<br />
		<div class="module">
			<div class="subModule">
				<table align="center">
					<tr>
						<td align="right">
							<@spring.message "routingNumber" />
						</td>
						<td align="left">
							<@spring.formInput "webTransaction.debitAccount.routingNumber", 'size="15"' />
						</td>
					</tr>
					<tr>
						<td align="right">
							<@spring.message "accountNumber" />
						</td>
						<td align="left">
							<@spring.formInput "webTransaction.debitAccount.accountNumber", 'size="15"' />
						</td>
					</tr>
					<tr>
						<td align="right">
							<@spring.message "amount" />
						</td>
						<td align="left">
							<@spring.formInput "webTransaction.amount", 'size="15"' />
						</td>
					</tr>
					<tr>
						<td align="right">
							<@spring.message "accountType" />
						</td>
						<td>
							<@spring.formRadioButtons "webTransaction.accountType", accountTypeMap, " " />
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<input id="submit" type="submit" name="submit" value="<@spring.message "submit" />" />
						</td>
					</tr>
				</table>
			</div>
		</div>
	</form>
	<div id="spinme"></div>
	<span id="errors">
		<@spring.bind "webTransaction.*" />
		<#list spring.status.errorMessages as error>* ${error?cap_first}<br /></#list>
	</span>
	<br />
	<div class="summary">
		<#if creditUser?? && transaction??>
			You transferred $${transaction.amount} to ${creditUser.name}!
		</#if>
	</div>
	</div>
</body>
</html>
